/*
  Copyright © 2014 Allen County Public Library.

  ACPL Mobile is free software: This program is distributed and you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.  ACPL Mobile is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, including without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ACPL Mobile. If not, see http://www.gnu.org/licenses/.
 * Author: James Harpe
 * 
 * 
 * Description: This class contains useful helper methods relating to location information. 
 */

package us.in.lib.acpl.Mobile_ACPL.location;

import android.location.Location;
import android.location.LocationManager;
import us.in.lib.acpl.Mobile_ACPL.R;

public class LocationInfo {

    //ACPL: Obviously this is all ACPL specific info

	public static final double LOCATION_NOT_AVAILABLE = -1;

	public static final double[] COORDS_MAIN = { 41.077025, -85.142437 };
	public static final double[] COORDS_ABOITE = { 41.035665, -85.259786 };
	public static final double[] COORDS_DUPONT = { 41.177665, -85.134677 };
	public static final double[] COORDS_GEORGETOWN = { 41.101988, -85.056866 };
	public static final double[] COORDS_GRABILL = { 41.212211, -84.970886 };
	public static final double[] COORDS_HESSEN_CASSEL = { 41.031796, -85.097625 };
	public static final double[] COORDS_LITTLE_TURTLE = { 41.095240, -85.153876 };
	public static final double[] COORDS_MONROEVILLE = { 40.975113, -84.868280 };
	public static final double[] COORDS_NEW_HAVEN = { 41.070966, -85.011507 };
	public static final double[] COORDS_PONTIAC = { 41.065065, -85.128380 };
	public static final double[] COORDS_SHAWNEE = { 41.032406, -85.135308 };
	public static final double[] COORDS_TECUMSEH = { 41.096747, -85.121656 };
	public static final double[] COORDS_WAYNEDALE = { 41.020401, -85.165520 };
	public static final double[] COORDS_WOODBURN = { 41.110287, -84.855874 };
	public static final double METERS_PER_MILE = 1609.344;

	public static final String MAIN_ADDRESS = "900 Library Plaza\nFort Wayne, IN 46802";
	public static final String ABOITE_ADDRESS = "5630 Coventry Lane\nFort Wayne, IN 46804";
	public static final String DUPONT_ADDRESS = "536 E.Dupont Road\nFort Wayne, IN 46825";
	public static final String GEORGETOWN_ADDRESS = "6600 East State Blvd.\nFort Wayne, IN 46815";
	public static final String GRABILL_ADDRESS = "13521 State Street\nGrabill, IN 46741";
	public static final String HESSEN_CASSEL_ADDRESS = "3030 East Paulding Road\nFort Wayne, IN 46816";
	public static final String LITTLE_TURTLE_ADDRESS = "2201 Sherman Blvd.\nFort Wayne, IN 46808";
	public static final String MONROEVILLE_ADDRESS = "115 Main Street\nMonroeville, IN 46773";
	public static final String NEW_HAVEN_ADDRESS = "648 Green Street\nNew Haven, IN 46774-1681";
	public static final String PONTIAC_ADDRESS = "2215 S. Hanna Street\nFort Wayne, IN 46803-2431";
	public static final String SHAWNEE_ADDRESS = "5600 Noll Avenue\nFort Wayne, IN 46806";
	public static final String TECUMSEH_ADDRESS = "1411 East State Blvd.\nFort Wayne, IN 46805";
	public static final String WAYNEDALE_ADDRESS = "2200 Lower Huntington Road\nFort Wayne, IN 46819";
	public static final String WOODBURN_ADDRESS = "4701 State Road 101 North\nWoodburn, IN 46797";

	public static final String MAIN_PHONE = "(260) 421-1200";
	public static final String ABOITE_PHONE = "(260) 421-1310";
	public static final String DUPONT_PHONE = "(260) 421-1315";
	public static final String GEORGETOWN_PHONE = "(260) 421-1320";
	public static final String HESSEN_CASSEL_PHONE = "(260) 421-1330";
	public static final String LITTLE_TURTLE_PHONE = "(260) 421-1335";
	public static final String MONROEVILLE_PHONE = "(260) 421-1340";
	public static final String NEW_HAVEN_PHONE = "(260) 421-1345";
	public static final String PONTIAC_PHONE = "(260) 421-1350";
	public static final String SHAWNEE_PHONE = "(260) 421-1355";
	public static final String TECUMSEH_PHONE = "(260) 421-1360";
	public static final String WAYNEDALE_PHONE = "(260) 421-1365";
	public static final String WOODBURN_PHONE = "(260) 421-1370";
	public static final String GRABILL_PHONE = "(260) 421-1325";

	public static final String[] MAIN_HOURS = { "9am-9pm", "9am-9pm",
			"9am-9pm", "9am-9pm", "9am-6pm", "9am-6pm", "12pm-5pm*",
			"*Closed Sundays from Memorial Day to Labor Day " };
	public static final String[] ABOITE_HOURS = { "10am-9pm", "10am-9pm",
			"10am-9pm", "10am-9pm", "10am-6pm", "10am-6pm", "Closed", "" };
	public static final String[] DUPONT_HOURS = { "10am-9pm", "10am-9pm",
			"10am-9pm", "10am-9pm", "10am-6pm", "10am-6pm", "Closed", "" };
	public static final String[] GEORGETOWN_HOURS = { "10am-9pm", "10am-9pm",
			"10am-9pm", "10am-9pm", "10am-6pm", "10am-6pm", "Closed", "" };
	public static final String[] GRABILL_HOURS = { "10am-9pm", "10am-9pm",
			"10am-6pm", "10am-9pm", "10am-6pm", "10am-6pm*", "Closed",
			"*Closed Saturdays from Memorial Day to Labor Day " };
	public static final String[] HESSEN_CASSEL_HOURS = { "10am-9pm",
			"10am-9pm", "10am-6pm", "10am-9pm", "10am-6pm", "10am-6pm*",
			"Closed", "*Closed Saturdays from Memorial Day to Labor Day " };
	public static final String[] LITTLE_TURTLE_HOURS = { "10am-9pm",
			"10am-9pm", "10am-9pm", "10am-6pm", "10am-6pm", "10am-6pm*",
			"Closed", "*Closed Saturdays from Memorial Day to Labor Day " };
	public static final String[] MONROEVILLE_HOURS = { "12pm-5pm, 6pm-9pm",
			"10am-12pm, 1pm-6pm", "12pm-5pm, 6pm-9pm", "10am-12pm, 1pm-6pm",
			"10am-12pm, 1pm-6pm", "10am-2pm*", "Closed",
			"*Closed Saturdays from Memorial Day to Labor Day " };
	public static final String[] NEW_HAVEN_HOURS = { "10am-9pm", "10am-9pm",
			"10am-9pm", "10am-6pm", "10am-6pm", "10am-6pm*", "Closed",
			"*Closed Saturdays from Memorial Day to Labor Day " };
	public static final String[] PONTIAC_HOURS = { "10am-9pm", "10am-9pm",
			"10am-6pm", "10am-9pm", "10am-6pm", "10am-6pm*", "Closed",
			"*Closed Saturdays from Memorial Day to Labor Day " };
	public static final String[] SHAWNEE_HOURS = { "10am-9pm", "10am-9pm",
			"10am-9pm", "10am-6pm", "10am-6pm", "10am-6pm", "Closed", "" };
	public static final String[] TECUMSEH_HOURS = { "10am-9pm", "10am-9pm",
			"10am-6pm", "10am-9pm", "10am-6pm", "10am-6pm*", "Closed",
			"*Closed Saturdays from Memorial Day to Labor Day " };
	public static final String[] WAYNEDALE_HOURS = { "10am-9pm", "10am-9pm",
			"10am-6pm", "10am-9pm", "10am-6pm", "10am-6pm*", "Closed",
			"*Closed Saturdays from Memorial Day to Labor Day " };
	public static final String[] WOODBURN_HOURS = { "10am-12pm, 1pm-6pm",
			"12pm-5pm, 6pm-9pm", "10am-12pm, 1pm-6pm", "12pm-5pm, 6pm-9pm",
			"10am-12pm, 1pm-6pm", "10am-2pm*", "Closed",
			"*Closed Saturdays from Memorial Day to Labor Day " };

	public static int getImageId(String location) {

		if (location.equals("Main")) {
			return R.drawable.main;
		} else if (location.equals("Aboite")) {
			return R.drawable.aboite;
		} else if (location.equals("Dupont")) {
			return R.drawable.dupont;
		} else if (location.equals("Georgetown")) {
			return R.drawable.georgetown;
		} else if (location.equals("Grabill")) {
			return R.drawable.grabill;
		} else if (location.equals("Hessen Cassel")) {
			return R.drawable.hessencassel;
		} else if (location.equals("Little Turtle")) {
			return R.drawable.littleturtle;
		} else if (location.equals("Monroeville")) {
			return R.drawable.monroeville;
		} else if (location.equals("New Haven")) {
			return R.drawable.newhaven;
		} else if (location.equals("Pontiac")) {
			return R.drawable.pontiac;
		} else if (location.equals("Shawnee")) {
			return R.drawable.shawnee;
		} else if (location.equals("Tecumseh")) {
			return R.drawable.tecumseh;
		} else if (location.equals("Waynedale")) {
			return R.drawable.waynedale;
		} else {
			return R.drawable.woodburn;
		}

	}

	public static String getAddress(String location) {
		if (location.equals("Main")) {
			return MAIN_ADDRESS;
		} else if (location.equals("Aboite")) {
			return ABOITE_ADDRESS;
		} else if (location.equals("Dupont")) {
			return DUPONT_ADDRESS;
		} else if (location.equals("Georgetown")) {
			return GEORGETOWN_ADDRESS;
		} else if (location.equals("Grabill")) {
			return GRABILL_ADDRESS;
		} else if (location.equals("Hessen Cassel")) {
			return HESSEN_CASSEL_ADDRESS;
		} else if (location.equals("Little Turtle")) {
			return LITTLE_TURTLE_ADDRESS;
		} else if (location.equals("Monroeville")) {
			return MONROEVILLE_ADDRESS;
		} else if (location.equals("New Haven")) {
			return NEW_HAVEN_ADDRESS;
		} else if (location.equals("Pontiac")) {
			return PONTIAC_ADDRESS;
		} else if (location.equals("Shawnee")) {
			return SHAWNEE_ADDRESS;
		} else if (location.equals("Tecumseh")) {
			return TECUMSEH_ADDRESS;
		} else if (location.equals("Waynedale")) {
			return WAYNEDALE_ADDRESS;
		} else {
			return WOODBURN_ADDRESS;
		}
	}

	public static Location getLocation(String locationName) {
		Location loc = new Location(LocationManager.GPS_PROVIDER);

		if (locationName.equalsIgnoreCase("Main")) {
			loc.setLatitude(COORDS_MAIN[0]);
			loc.setLongitude(COORDS_MAIN[1]);
			return loc;
		} else if (locationName.equalsIgnoreCase("Aboite")) {

			loc.setLatitude(COORDS_ABOITE[0]);
			loc.setLongitude(COORDS_ABOITE[1]);
			return loc;
		} else if (locationName.equalsIgnoreCase("Dupont")) {

			loc.setLatitude(COORDS_DUPONT[0]);
			loc.setLongitude(COORDS_DUPONT[1]);
			return loc;
		} else if (locationName.equalsIgnoreCase("Georgetown")) {
			loc.setLatitude(COORDS_GEORGETOWN[0]);
			loc.setLongitude(COORDS_GEORGETOWN[1]);
			return loc;
		} else if (locationName.equalsIgnoreCase("Grabill")) {
			loc.setLatitude(COORDS_GRABILL[0]);
			loc.setLongitude(COORDS_GRABILL[1]);
			return loc;
		} else if (locationName.equalsIgnoreCase("Hessen Cassel")) {
			loc.setLatitude(COORDS_HESSEN_CASSEL[0]);
			loc.setLongitude(COORDS_HESSEN_CASSEL[1]);
			return loc;
		} else if (locationName.equalsIgnoreCase("Little Turtle")) {
			loc.setLatitude(COORDS_LITTLE_TURTLE[0]);
			loc.setLongitude(COORDS_LITTLE_TURTLE[1]);
			return loc;
		} else if (locationName.equalsIgnoreCase("Monroeville")) {
			loc.setLatitude(COORDS_MONROEVILLE[0]);
			loc.setLongitude(COORDS_MONROEVILLE[1]);
			return loc;
		} else if (locationName.equalsIgnoreCase("New Haven")) {
			loc.setLatitude(COORDS_NEW_HAVEN[0]);
			loc.setLongitude(COORDS_NEW_HAVEN[1]);
			return loc;
		} else if (locationName.equalsIgnoreCase("Pontiac")) {
			loc.setLatitude(COORDS_PONTIAC[0]);
			loc.setLongitude(COORDS_PONTIAC[1]);
			return loc;
		} else if (locationName.equalsIgnoreCase("Shawnee")) {
			loc.setLatitude(COORDS_SHAWNEE[0]);
			loc.setLongitude(COORDS_SHAWNEE[1]);
			return loc;
		} else if (locationName.equalsIgnoreCase("Tecumseh")) {
			loc.setLatitude(COORDS_TECUMSEH[0]);
			loc.setLongitude(COORDS_TECUMSEH[1]);
			return loc;
		} else if (locationName.equalsIgnoreCase("Waynedale")) {
			loc.setLatitude(COORDS_WAYNEDALE[0]);
			loc.setLongitude(COORDS_WAYNEDALE[1]);
			return loc;
		} else {
			loc.setLatitude(COORDS_WOODBURN[0]);
			loc.setLongitude(COORDS_WOODBURN[1]);
			return loc;
		}
	}

	public static double locDistanceInMiles(Location loc, String library) {
		if (loc == null) {
			return LOCATION_NOT_AVAILABLE;
		} else {
			return (getLocation(library).distanceTo(loc) / METERS_PER_MILE);
		}
	}

	public static String getPhone(String location) {

		if (location.equals("Main")) {
			return MAIN_PHONE;
		} else if (location.equals("Aboite")) {
			return ABOITE_PHONE;
		} else if (location.equals("Dupont")) {
			return DUPONT_PHONE;
		} else if (location.equals("Georgetown")) {
			return GEORGETOWN_PHONE;
		} else if (location.equals("Grabill")) {
			return GRABILL_PHONE;
		} else if (location.equals("Hessen Cassel")) {
			return HESSEN_CASSEL_PHONE;
		} else if (location.equals("Little Turtle")) {
			return LITTLE_TURTLE_PHONE;
		} else if (location.equals("Monroeville")) {
			return MONROEVILLE_PHONE;
		} else if (location.equals("New Haven")) {
			return NEW_HAVEN_PHONE;
		} else if (location.equals("Pontiac")) {
			return PONTIAC_PHONE;
		} else if (location.equals("Shawnee")) {
			return SHAWNEE_PHONE;
		} else if (location.equals("Tecumseh")) {
			return TECUMSEH_PHONE;
		} else if (location.equals("Waynedale")) {
			return WAYNEDALE_PHONE;
		} else {
			return WOODBURN_PHONE;
		}
	}

	public static String[] getHours(String location) {
		if (location.equals("Main")) {
			return MAIN_HOURS;
		} else if (location.equals("Aboite")) {
			return ABOITE_HOURS;
		} else if (location.equals("Dupont")) {
			return DUPONT_HOURS;
		} else if (location.equals("Georgetown")) {
			return GEORGETOWN_HOURS;
		} else if (location.equals("Grabill")) {
			return GRABILL_HOURS;
		} else if (location.equals("Hessen Cassel")) {
			return HESSEN_CASSEL_HOURS;
		} else if (location.equals("Little Turtle")) {
			return LITTLE_TURTLE_HOURS;
		} else if (location.equals("Monroeville")) {
			return MONROEVILLE_HOURS;
		} else if (location.equals("New Haven")) {
			return NEW_HAVEN_HOURS;
		} else if (location.equals("Pontiac")) {
			return PONTIAC_HOURS;
		} else if (location.equals("Shawnee")) {
			return SHAWNEE_HOURS;
		} else if (location.equals("Tecumseh")) {
			return TECUMSEH_HOURS;
		} else if (location.equals("Waynedale")) {
			return WAYNEDALE_HOURS;
		} else {
			return WOODBURN_HOURS;
		}
	}

	public static String getSystemName(String loc) {
		if (loc.equalsIgnoreCase("Monroeville")) {
			return "mnroeville";
		} else if (loc.equalsIgnoreCase("New Haven")) {
			return "new_haven";
		} else if (loc.equalsIgnoreCase("Little Turtle")) {
			return "ltl_turtle";
		} else if (loc.equalsIgnoreCase("Hessen Cassel")) {
			return "hsn_cassel";
		} else if (loc.equalsIgnoreCase("All")) {
			return null;
		} else {
			return loc;
		}
	}

}
